package com.stooscloud.provider.web;

import com.stooscloud.JacksonUtil;
import com.stooscloud.provider.service.DSPService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
@RequestMapping(value = "/StoosCloud")
@Slf4j
public class JoinDSPController {

    @Autowired
    private DSPService dspService;
//    @PostMapping(value = "/bankInfoVerify")
//    public DSPWrapper bankInfoVerify(BankInfoDto bankInfo){
//        return dspService.bankInfoVerify(bankInfo);
//    }
//    @PostMapping(value = "/bankInfoVerify/{str}")
//    public DSPWrapper bankInfoVerify(@PathVariable String str){
//        return new DSPWrapper(2009,"交易成功");
//    }
//
//    @PostMapping(value = "/idcheck")
//    public IdChkWrapper idCheck(IdChkDto idChkDto){
//        return dspService.idcheck(idChkDto);
//    }

    @PostMapping(value = "/postOperators")
    public void postChannelJoin(HttpServletRequest request, HttpServletResponse response){
        this.getChannelJoin(request,response);
    }

    @GetMapping(value = "/getOperators")
    public void getChannelJoin(HttpServletRequest request, HttpServletResponse response){
        response.setContentType("application/json;charset=UTF-8");
        try {
            response.getWriter().write(JacksonUtil.toJson(dspService.handler(request)));
        } catch (IOException e) {
            log.error("返回信息失败!【errMsg】:{}",e.getMessage());
        }
    }

    @GetMapping(value = "/test")
    public String getTest(@RequestParam("name") String name){
        return name.toUpperCase();
    }

}
